package com.project.nimsen.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
 * TODO 在此加入类描述
 */
@Entity
@Table(name="user")
public class User implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1186920006857497042L;
	/**
	 * id
	 */
	private java.lang.String id;
	/**
	 * 用户名
	 */
	private java.lang.String username;
	/**
	 * 密码
	 */
	private java.lang.String password;
	/**
	 * 注册时间
	 */
	private java.util.Date regtime;
	/**
	 * 邮箱
	 */
	private java.lang.String mail;
	/**
	 * 0表示正常，1表示删除
	 */
	private java.lang.Integer active;

	public User(){
	}

	public User(
		java.lang.String id
	){
		this.id = id;
	}

	//get and set
	public void setId(java.lang.String value) {
		this.id = value;
	}
	
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public java.lang.String getId() {
		return this.id;
	}
	public void setUsername(java.lang.String value) {
		    if(StringUtils.isNotBlank(value)){
			 value=value.trim();
			}
		this.username = value;
	}
	@Column(name = "mail")
    public java.lang.String getMail() {
		return mail;
	}

	public void setMail(java.lang.String mail) {
		this.mail = mail;
	}

	@Column(name = "username")
	public java.lang.String getUsername() {
		return this.username;
	}
	
	public void setPassword(java.lang.String value) {
		    if(StringUtils.isNotBlank(value)){
			 value=value.trim();
			}
		this.password = value;
	}
	
     @Column(name = "password")
	public java.lang.String getPassword() {
		return this.password;
	}
		/*
	public String getregtimeString() {
		return DateUtils.convertDate2String(FORMAT_REGTIME, getregtime());
	}
	public void setregtimeString(String value) throws ParseException{
		setregtime(DateUtils.convertString2Date(FORMAT_REGTIME,value));
	}*/
	
	public void setRegtime(java.util.Date value) {
		this.regtime = value;
	}
	
     @Column(name = "regtime")
	public java.util.Date getRegtime() {
		return this.regtime;
	}
		/*
	public String getcretimeString() {
		return DateUtils.convertDate2String(FORMAT_CRETIME, getcretime());
	}
	public void setcretimeString(String value) throws ParseException{
		setcretime(DateUtils.convertString2Date(FORMAT_CRETIME,value));
	}*/
	
	public void setActive(java.lang.Integer value) {
		this.active = value;
	}
	
     @Column(name = "active")
	public java.lang.Integer getActive() {
		return this.active;
	}
	
	public String toString() {
		return new StringBuffer()
			.append("id[").append(getId()).append("],")
			.append("用户名[").append(getUsername()).append("],")
			.append("密码[").append(getPassword()).append("],")
			.append("注册时间[").append(getRegtime()).append("],")
			.append("0表示正常，1表示删除[").append(getActive()).append("],")
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof User == false) return false;
		if(this == obj) return true;
		User other = (User)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
}

	
